$(() => {
  let form = layui.form
  let layer = layui.layer
  $('.layui-container').particleground({
    dotColor: '#7ec7fd',
    lineColor: '#7ec7fd',
  })

  //登录功能
  $('#login').on('click', (e) => {
    e.preventDefault()
    let data = form.val('login')
    $.ajax({
      url: 'api/login',
      type: 'POST',
      data,
      success: (msg) => {
        if (msg.status === 0) {
          localStorage.setItem('mytoken', msg.token)
          location.href = './index.html'
        } else {
          layer.msg('登陆失败')
        }
      },
    })
  })
})
